import {
  CallHandler,
  ExecutionContext,
  Injectable,
  NestInterceptor,
} from '@nestjs/common';
import { map, Observable, tap } from 'rxjs';

@Injectable()
export class WrapResponseInterceptor implements NestInterceptor {
  intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
    console.log('interceptor before...');
    return (
      next
        .handle()
        // .pipe(tap((data) => console.log('interceptor after', data)));
        .pipe(map((data) => ({ data })))
    );
  }
}
